package components;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import util.Vector2D;
import entities.Entity;

public class SpriteView extends EntityView {

	private Image img;

	private float width;
	private float height;

	public SpriteView(Entity e, Image img) {
		super(e);
		this.img = img;
		width = img.getWidth();
		height = img.getHeight();
	}
	
	//TODO Implement a global image repository 
	public SpriteView(Entity e, String imgFile) throws SlickException {
		this(e, new Image(imgFile));
	}

	@Override
	public Image getImage() {
		return img;
	}

	@Override
	public Vector2D getPosition() {
		return new Vector2D(entity.getX() - width / 2.0f, entity.getY()
				- height / 2.0f);
	}

	@Override
	public float getWidth() {
		return width;
	}

	@Override
	public float getHeight() {
		return width;
	}

}
